<extend name="Layout/ins_page" />
<block name="content">
	{:W('PageHeader/simple',array('name'=>'修改任务'))}
	<div class="sub-frame gray">
	<form method='post' id="form_data" name="form_data" enctype="multipart/form-data"   >
		<input type="hidden" id="id" name="id" value="{$vo.id}">
		<input type="hidden" id="ajax" name="ajax" value="0">
		<input type="hidden" id="executor" name="executor" value="{$vo.executor}">
		<input type="hidden" id="assign_user" name="assign_user" value="{$vo.assign_user}">
		<input type="hidden" id="opmode" name="opmode" value="edit">

		<div class="layui-form-item">
			<label class="layui-form-label" for="name">标题：</label>
			<div class="layui-input-block">
				<input class="layui-input" type="text" id="name" name="name" value="{$vo.name}"  check="required" info="请输入文件名">
			</div>
		</div>
		<div class="layui-form-item">
				<label class="layui-form-label" for="name">指派给：</label>
				<div class="layui-input-block">
					<div id="actor_wrap" class="input-box">
						<a class="add-on" id="popup_actor"><i class="fa fa-user"></i> </a>
						<div class="wrap" >
							<span class="address_list">{$vo.executor|show_contact="edit"}</span>
							<span class="text" >
								<input class="letter" type="text"  >
							</span>
						</div>
						<div class="search dropdown ">
							<ul class="dropdown-menu"></ul>
						</div>
					</div>
				</div>
			</div>
		<div class="layui-form-item">
			<label class="layui-form-label" for="plan_time">期望完成时间：</label>
			<div class="layui-input-block">
				<input class="layui-input input-date-time" type="text" id="expected_time" name="expected_time" value="{$vo.expected_time}"readonly="readonly" >
			</div>
		</div>
		<div class="layui-form-item">
				<label class="layui-form-label" for="content">任务描述：</label>
				<div class="layui-input-block">
					<textarea class="editor" id="content" name="content" style="width:100%;height:300px;" check="required" info="请输入内容">{$vo.content}</textarea>
				</div>
			</div>
		

		<div class="layui-form-item">
			<label class="layui-form-label" for="name">附件：</label>
			<div class="layui-input-block">
				{:W('FileUpload/edit',array('add_file'=>$vo['add_file']))}
			</div>
		</div>
		<div class="layui-form-item">
				<div class="action layui-input-block">
					<input class="btn" type="button" value="保存" id="btn_save">
					<input class="btn btn-cancel" type="button" value="取消" onclick="go_return_url();">
				</div>
			</div>
	</form>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
	layui.use(['global', 'editor'], function() {
			var $ = layui.jquery;
		
		
		$("#popup_actor").on('click', function() {
				winopen("{:U('popup/task')}", 560, 470);
			});
		
		
		
			$("#btn_save").on('click', function() {
				$("#executor").val("");
				$("#actor_wrap span.address_list span").each(function() {
					$("#executor").val($("#executor").val() + $(this).find("b").text() + '|' + $(this).attr("data") + ";");
				});
				$html = $("#executor").val();
				var re = new RegExp("dept_", "g");
				var arr = $html.match(re);
				if (arr != null) {
					$dept_count = arr.length;
					$total_count = $html.split(';').length - 1;
					if ($dept_count != $total_count) {
						layer.msg('部门和人员不能同时选择');
						return false;
					}
				}
				send_form('form_data', '{:U("save")}', '', function(ret) {
					if (ret.status == 1) {
						parent.layer.msg(ret.info);
						parent.layer.close(index);
						parent.location.reload(true);
					} else {
						parent.layer.msg(ret.info);
						return false;
					};
				});
			});
$(document).on("click", ".inputbox .address_list a.del", function() {
				$(this).parent().parent().remove();
			});
		
		});
	

	</script>
</block>